import axios from "axios";
export const getnews=(data)=>{
    return{
        type:"GETNEWS",
        payload:data
    }   
   }
export const  fetchnews=(params={page:1})=>{
       return dispatch=>{
           var url=`http://localhost:3000/news?_page=${params.page}&_limit=6&_sort=id&_order=desc`
           axios({
               url:url,
               method:"get"
           }).then(res=>{
            //    console.log('news',res.headers);
            //    console.log('news',res.data);
               var obj={
                   rows:res.data,
                   totle:res.headers['x-total-count']
               }
               dispatch(getnews(obj));
           })
       }
}